package com.atguigu.gmall.task.controller;

import com.atguigu.gmall.common.result.Result;
import com.atguigu.gmall.task.config.DeadLetterConfig;
import com.atguigu.gmall.task.service.RabbitService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author: 李旭
 * @create: 2021-07-24 11:34
 *
 * 发消息
 **/
@RestController
public class SendMessageController {

    @Autowired
    private RabbitService rabbitService;
    //发消息
    @GetMapping("/sendMessage")
    public Result sendMessage(){
/*        rabbitTemplate.convertAndSend(
                "exchange112",
                "routingKey11","我是消息");*/
        rabbitService.sendMessage(  "exchange11",
                "routingKey11","我是消息");
        return Result.ok();
    }

    //发送延迟消息 （基于死信的）
    @GetMapping("/sendDeadLetterMessage")
    public Result sendDeadLetterMessage(){

        rabbitService.sendDeadLetterMessage(DeadLetterConfig.exchange_dead,
                DeadLetterConfig.routing_dead_1,"我是死信消息",8);
        return Result.ok();
    }
}
